package com.supermap.tool;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationListener;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.event.ContextRefreshedEvent;

import com.supermap.redis.service.MysqlControllerAop;
import com.supermap.redis.tool.RedisToo;

/**
 * 
* @ClassName: DataSourceInitListener 
* @Description: 启动监听
* @author yuyao
* @date 2017年12月28日 下午5:41:40
 */
@Configuration
public class DataSourceInitListener implements ApplicationListener<ContextRefreshedEvent>{

	@Autowired
	RedisToo redisToo = new RedisToo();
	
	@Override
	public void onApplicationEvent(ContextRefreshedEvent ev) {
		//防止重复执行。
        if(ev.getApplicationContext().getParent() == null){
        	try {
        		redisToo.findOne("1");
			} catch (Exception e) {
				MysqlControllerAop.setUpdateqjkg(false);//不走缓存
				System.out.println("************redis缓存库链接失败！请检查redis链接！****************");
			}
        	
        }
		
	}

}
